package thired.algorithm;

import java.util.Scanner;

public class SolveQuestion {
    public static int process(int[] t1, int[] s1, int[] t2, int[] s2, int[] ans, int index, int time){
        if(index == t1.length){
            return time >= 0 ? 0 : Integer.MIN_VALUE;
        }
        if(time < 0){
            return Integer.MIN_VALUE;
        }
        if(time >= t1[index]){
            int p1 = s1[index] + process(t1, s1, t2, s2, ans, index + 1, time - t1[index]);
            int p2 = s2[index] + process(t1, s1, t2, s2, ans, index + 1, time - t2[index]);
            int p3 =  process(t1, s1, t2, s2, ans, index + 1, time);
            if(p1 > p2 && p1 > p3){
                ans[index] = 0;
            }
            if(p2 > p1 && p2 > p3){
                ans[index] = 1;
            }
            if(p3 > p1 && p3 > p2){
                ans[index] = 2;
            }
            return Math.max(p1, Math.max(p2, p3));
        }
        else if(time >= t2[index]){
            int p2 = s2[index] + process(t1, s1, t2, s2, ans, index + 1, time - t2[index]);
            int p3 =  process(t1, s1, t2, s2, ans, index + 1, time);
            if(p2 >= p3){
                ans[index] = 1;
            }
            if(p3 > p2){
                ans[index] = 2;
            }
            return Math.max(p2, p3);
        }
        else{
            int p3 =  process(t1, s1, t2, s2, ans, index + 1, time);
            ans[index] = 2;
            return p3;
        }

    }

    public static void dp(int[] t1, int[] s1, int[] t2, int[] s2, int[] ans,int t){
        int[][] dp = new int[t1.length + 1][t + 1];
        //dp[t1.length][i] = 0;
        int i = 0;
        for (int index = t1.length - 1; index >= 0; index--) {
            for (int time = 0; time < t + 1; time++) {
                if(time >= t1[index]){
                    int p1 = s1[index] + dp[index + 1][time - t1[index]];
                    int p2 = s2[index] + dp[index + 1][time - t2[index]];
                    int p3 = dp[index + 1][time];
                    if(time == t){
                        if(p1 >= p2 && p1 >= p3){
                            ans[i++] = 0;
                        }
                        if(p2 > p1 && p2 >=  p3){
                            ans[i++] = 1;
                        }
                        if(p3 > p1 && p3 > p2){
                            ans[i++] = 2;
                        }
                    }
                    dp[index][time] = Math.max(p1, Math.max(p2, p3));
                }
                else if(time >= t2[index]){
                    int p2 = s2[index] + dp[index + 1][time - t2[index]];
                    int p3 =  dp[index + 1][time];
                    if(time == t){
                        if(p2 >= p3){
                            ans[i++] = 1;
                        }
                        if(p3 > p2){
                            ans[i++] = 2;
                        }
                    }

                    dp[index][time] = Math.max(p2, p3);
                }
                else{
                    int p3 =  dp[index + 1][time];
                    if(time == t){
                        ans[i++] = 2;
                    }
                    dp[index][time] = p3;
                }
            }

        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//题目数
        int t = sc.nextInt();//时长
        int[] t1 = new int[n];//正解用时
        int[] t2 = new int[n];//暴力用时
        int[] s1 = new int[n];//正解得分
        int[] s2 = new int[n];//暴力得分
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            String[] s = sc.nextLine().split(" ");
            t1[i] = Integer.parseInt(s[0]);
            s1[i] = Integer.parseInt(s[1]);
            t2[i] = Integer.parseInt(s[2]);
            s2[i] = Integer.parseInt(s[3]);
        }
        int[] ans = new int[n];//0 -> 正解 1 -> 暴力 2 -> 跳过
       process(t1, s1, t2, s2, ans,0,t);
        for (int i = 0; i < n; i++) {
            System.out.print(ans[i] + " ");
        }
    }
}
